package com.yunsom.testdemo.design.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Xbao
 * @description
 * @date 2022/6/22 13:54
 */
public class Employee {

  private String name;
  private int salary;
  private String depart;
  private List<Employee> subordinates;

  public Employee(String name, String depart, int salary) {
    this.name = name;
    this.salary = salary;
    this.depart = depart;
    this.subordinates = new ArrayList<>();
  }

  public List<Employee> getSubordinates() {
    return subordinates;
  }

  public void add(Employee employee){
    this.subordinates.add(employee);
  }

  public void remove(Employee employee){
    this.subordinates.remove(employee);
  }

  @Override
  public String toString() {
    return "Employee{" +
        "name='" + name + '\'' +
        ", depart='" + depart + '\'' +
        ", salary=" + salary +
        '}';
  }
}
